<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/swiper.min.css">
    <style>
        .box {
            width: 600px;
            height: 300px;
        }

        .list {
            width: 600px;
            height: 50px;
            margin-top: 20px;
        }

        #gallery {
            border: 1px solid #ccc;
        }

        .list .swiper-slide {
            margin-right: 5px;
            height: 80px;
            /* border: 1px solid #ccc; */
        }

        .list .active {
            opacity: 1;
        }

        img {
            width: 100%;
            height: 100%;
        }

        #thumbs {
            height: 100px;
        }

        #box {
            display: flex;
            justify-content: space-around;
            background-color: #ccc;
            height: 100%;
            padding-top: 10px;
        }
    </style>
</head>

<body>
    <div id="gallery" class="swiper-container box">
        <div class="swiper-wrapper">
            <div class="swiper-slide"><img src="./img/g1.jpg" alt=""></div>
            <div class="swiper-slide"><img src="./img/g2.jpg" alt=""></div>
            <div class="swiper-slide"><img src="./img/g3.jpg" alt=""></div>
            <div class="swiper-slide"><img src="./img/g4.jpg" alt=""></div>
        </div>
    </div>
    <div id="thumbs" class="swiper-container list">
        <div class="swiper-wrapper" id="box">
            <div class="swiper-slide o"><img src="./img/g1.jpg" alt=""></div>
            <div class="swiper-slide o"><img src="./img/g2.jpg" alt=""></div>
            <div class="swiper-slide o"><img src="./img/g3.jpg" alt=""></div>
            <div class="swiper-slide o"><img src="./img/g4.jpg" alt=""></div>
        </div>
    </div>
    <script src="js/swiper.min.js"></script>
    <script>
        var mySwiper = new Swiper('#gallery', {
            // 写主图的属性
            loop: true,
            thumbs: {
                // 缩略图的属性写在这里面
                swiper: {
                    el: '#thumbs', //注意此处的设置方式
                    slidesPerView: 5,
                },
                slideThumbActiveClass: 'active'
            },

        });
        var o = document.getElementsByClassName("o")
        for (let i = 0; i < o.length; i++) {

            o[i].onclick = function () {
                for (var j = 0; j < o.length; j++) {
                    o[j].style.border = "none"
                }
                this.style.border = "3px solid green"
            }
        }
    </script>
</body>

</html>